package com.majsubtense.core.components;

import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;

public class Render extends Component {
    public static final ComponentType<Render> ANY;
    private final Canvas canvas = new Canvas();
    private final GraphicsContext graphicsContext = canvas.getGraphicsContext2D();

    public Render() {
        super(Render.ANY);
    }

    public void paint(Image image, float[] position) {
        graphicsContext.drawImage(
                image,
                position[0],
                position[1]
        );
    }

    public void paint(Image image, float x, float y) {
        graphicsContext.drawImage(image, x, y);
    }

    public Canvas getCanvas() {
        return canvas;
    }

    public GraphicsContext getGraphicsContext() {
        return graphicsContext;
    }

    static {
        ANY = new ComponentType<>(ComponentType.ROOT, "RENDER");
    }
}
